refactoring to make future testing easier