modified clustering algorithm