Adding missing curly braces in nested if/else statements