Simplify nested if