fixed a bug in rand_index implementation