fix the index error