if statement refactor