Avoid nested if statement