start refactoring to make testing easier