the refactored code