Refactored code to handle "move" method