test passed after refactoring