fix index encode bug