fix undo/redo functionality