Updated the delete function.