tests passed after refactoring