Added undo and redo functions