private void replaceWires(List<List<Gate>> layersOfGates,int numberOfInputs,
			int startOutputWire) {
		for (List<Gate> list: layersOfGates) {
			for (Gate g: list) {
				int leftIndex = g.getLeftWireIndex();
				int rightIndex = g.getRightWireIndex();
				int outputWireIndex = g.getOutputWireIndex();
				if (outputWireIndex < startOutputWire) {
					int newIndex = currentWireIndex++;
					g.setOutputWireIndex(newIndex);
					replacementMap.put(outputWireIndex, newIndex);
				} else {
					replacementMap.put(outputWireIndex, outputWireIndex);
				}
				
				if (leftIndex >= numberOfInputs) {
					g.setLeftWireIndex(replacementMap.get(leftIndex));
				}

				if (rightIndex >= numberOfInputs) {
					g.setRightWireIndex(replacementMap.get(rightIndex));
				}
			}
			Collections.sort(list, new OutputWireComparator());
		}
	}