added function on update and on delete