Simplify if to reduce nesting level