refactoring to simplify