finished the refactoring with mixed results