Updated undo move function