refactored v1 for testability
prepared v1 for refactoring
formatting