Undo and redo bug fixed