public Solution backtrackingSearchMRVLCV(final PartialAssignment assign, final DomainList domainlist) {

		count = count + 1;
				
		// Clone the assignment, since we don't want to clobber the values already assigned
		PartialAssignment pa = (PartialAssignment) assign.clone();
		
		ArrayList<Integer> unassignedVars = pa.getUnassignedVariables();
		// If the assignment is complete, test it
		if(unassignedVars.size() == 0) {
			if(checkAssignment(pa) ) {
				// solution found!
				System.out.println("SOLUTION:");
				Map<String,String> result = pa.prettyPrint(variableNames, valueNames);
				return new Solution(true, result);
			} else{
				return new Solution(false, null);
			}
		} else {
			Solution solutionFound = new Solution(false,null);
			// choose the first temporarily
			int variable = unassignedVars.get(0);
			int size = Integer.MAX_VALUE;
			for (Integer v : unassignedVars)
			{
				if (domainlist.getValues(v).size() < size) //choose the one with the smallest domain
				{
					size = domainlist.getValues(v).size();
					variable = v;
				}
			}
			PriorityQueue<priorInt> order = new PriorityQueue<priorInt>();
			
			int o = 0;
			for(Integer value : domainlist.getValues(variable))
			{
				PartialAssignment ta = (PartialAssignment) assign.clone();
				ta.set(variable, value);
				order.add(new priorInt(value,ta.getUnassignedVariables().size()));
				o++;
			}
			//ordered by least constraining value
			for(int i=1; i < domainlist.getValues(variable).size(); i++)
			{
				if (!solutionFound.value)
				{
					Integer value = order.poll().value;
					pa.set(variable, value);
					//DomainList newdomainlist = forwardCheck(variable, value, pa, domainlist);
					solutionFound = backtrackingSearchMRVLCV(pa, domainlist);
				}
			}
			return solutionFound;
		}
	}