finished refactor, all tests passing again