fixing refactored code