Merge if statements - code simplification