fix distance matrix