Finished calculate_segment_rank