continued refactor for testability