modified clustering to be faster (I hope!)