if statement refactoring