Fix index bug in data generator