all tests green, but code smells; needs refactoring