Updated delete function.