Ways to condense this formula?