remove unnecessary nested if