Fixing typo in calculation of the index into the array