fixed logical error found in undo and redo