added my refactored code