refactoring to support tests