public synchronized SignedBlock createBestBlock(WeightedIdentity identity) {

		// this is not proven but it proves basic functionality

		// cycle through the leaf nodes

		// keep the best block on hand
		SignedBlock bestBlock = null;
		double bestScore = 0;

		// problem is that _leaves_ is being modified while iterating
		// probably by calling addBlock while in this loop.

		// Exception in thread "Thread-2"
		// java.util.ConcurrentModificationException
		// at java.util.HashMap$HashIterator.nextEntry(HashMap.java:793)
		// at java.util.HashMap$KeyIterator.next(HashMap.java:828)
		// at
		// org.altchain.ConfidenceChains.Simulation.BlockTree.BlockTree.createBestBlock(BlockTree.java:187)
		// at
		// org.altchain.ConfidenceChains.Simulation.MultiThreaded.BlockTreeClientSimulatorThread.runMainLoop(BlockTreeClientSimulatorThread.java:164)
		// at
		// org.altchain.ConfidenceChains.Simulation.MultiThreaded.SimpleClientSimulatorThread.run(SimpleClientSimulatorThread.java:75)

		// http://stackoverflow.com/questions/8189466/java-util-concurrentmodificationexception
		
		synchronized (leaves) {

			for (Node leaf : leaves) {

				// temporarily add a child node

				SignedBlock sb = new SignedBlock(leaf.block, identity);

				Node testNode = new Node(sb);

				leaf.children.add(testNode);
				testNode.parent = leaf;

				// now compute confidence score

				double thisScore = testNode.computeNodeConfidenceScore();
				if (thisScore > bestScore) {
					bestScore = thisScore;
					bestBlock = sb;
				}

				// now detach the node
				leaf.children.remove(testNode);
				lookup.remove(testNode.block.id);

				// node gets destroyed by loop scope

			}

		}

		return bestBlock;

	}