change update function and add #delete method