updated to balance clusters, more optimized, faster