added implementation of undo/redo