working on refactoring to make testing easier