Fixed index calculation

Altered the index calculation so that every entry in the 'rnd' array is accessed exactly once.