refine abf1b18 to remove nested if