fixing index bug