add undo functionality