Fix undo problem