Too many nested if statements