refactor if