all tests passing, needs refactoring