fix bucket index calculation