creating a distance matrix