Write if logic more concisely