fix to_dist_matrix method