refactor if else