completed the sampleIndex prototype