making undo option work