fixed index bug