Fix incorrect type of index variable