check if index exists before deleting it