refactoring if statement