Fix index bug