bug fix for index calculation