Improved the undo mode