fixing nested if error