worked
refactored code