small refactoring to make testing easier.