Updated the delete function