Added distance function as parameter in kmeans