nested if statements print correctly