simplify nested if-statements