fix the current index bug