implemented undo/redo for add-template