refactoring if staments