made tests pass after refactoring