simplifying and refactoring