redefined Distance and FindNearestCentroid