refactoring in preparation for testing