refactoring the code
refactored code