findClosestCentroid function has been implemented