fix the index bug