fix nested if statements