Simplify if logic