finish sts distance clustering function.