fixed find_shortest_index