Refactored the code with some movement.