fixed bugs related to undo-redo