Fixing index bug