Fixed the delete function