Update count_distances.m