public void setData(Instances instances) throws Exception {
		// sync order of variables
		int [] order = new int [getNrOfNodes()];
		for (int iNode = 0; iNode < getNrOfNodes(); iNode++) {
			String sName = getNodeName(iNode);
			int nNode = 0;
			while (nNode < getNrOfNodes() && !sName.equals(instances.attribute(nNode).name())) {
				nNode++;
			}
			if (nNode >= getNrOfNodes()) {
				throw new Exception("Cannot find node named [[[" + sName + "]]] in the data");
			}
			order[iNode] = nNode;
		}
		Reorder reorderFilter = new Reorder();
		reorderFilter.setAttributeIndicesArray(order);
		reorderFilter.setInputFormat(instances);
		instances = Filter.useFilter(instances, reorderFilter);
		// filter using discretization/missing values filter
		Instances newInstances = new Instances(m_Instances, 0);
		if (m_DiscretizeFilter == null && m_MissingValuesFilter == null) {
			newInstances = normalizeDataSet(instances);
		} else {
			for (int iInstance = 0; iInstance < instances.numInstances(); iInstance++) {
				newInstances.add(normalizeInstance(instances.instance(iInstance)));
			}
		}
		//sanity check
		for (int iNode = 0; iNode < getNrOfNodes(); iNode++) {
			if (newInstances.attribute(iNode).numValues() != getCardinality(iNode)) {
				throw new Exception("Number of values of node [[[" + getNodeName(iNode) + "]]] differs in (discretized) dataset." );
			}
		}
		// if we got this far, all is ok with the data set and
		// we can replace data set of Bayes net
		m_Instances = newInstances;
	}