fixed incrementing index bug