public int recalcMembersip() {
	final int maxCentroidSize = new Double(this.docs.size() / 1.2).intValue();
	final Set<Integer> bestCentroids = new HashSet<Integer>();
	int bestCentroid;
	final List<List<Integer>> newMembership = new ArrayList<List<Integer>>();
	boolean toContinue = true;
	int change = 0;
	while (toContinue) {
	    change = 0;
	    for (int i = 0; i < this.membership.size(); i++) {
		newMembership.add(new ArrayList<Integer>());
	    }

	    for (int i = 0; i < this.docs.size(); i++) {
		bestCentroid = findClosestCentroid(i);
		if (!this.membership.get(bestCentroid).contains(i)) {
		    change++;
		}
		newMembership.get(bestCentroid).add(i);

	    }
	    toContinue = false;
	    for (int i = 0; i < this.membership.size() && this.advanceMod; i++) {
		if (this.membership.get(i).size() > maxCentroidSize) {
		    if (bestCentroids.size() == this.centroids.size()) {
			toContinue = false;
			continue;
		    }
		    final Random rand = new Random();
		    bestCentroids.add(this.centroids.get(i));
		    this.centroids.set(i, new Double(this.docs.size() * rand.nextDouble()).intValue());

		    toContinue = true;
		    newMembership.clear();
		    if (bestCentroids.size() == this.centroids.size()) {
			this.centroids = new ArrayList<Integer>(bestCentroids);
		    }
		}
	    }
	}

	this.membership = newMembership;
	return change;

    }