Fixed bug in the redo and undo