fix bug that deletes index