Refactored
Refactored the code