initial refactor, all tests green