Updated delete function