commented clustering algorithm