creation of distance matrix