refactored code again