Updated code handling edit/delete error