Fix delete function