public static Alignment score_all_refs(String hyp, 
					      List<String> refs,
					      List<String> reflens,
					      List<String> refids, 
					      String refspan,
					      String hypspan,
					      CostFunction costfunc,
					      TerScorer calc) {
	double totwords = 0;
	String ref;
	String refid = "";
	String bestref = "";
	@SuppressWarnings("unused") String reflen = "";

	Alignment bestresult = null;
	
	if(has_span && refs.size() > 1) {
	    System.out.println("Error, translation spans should only be used with SINGLE reference");
	    System.exit(1);
	}

	calc.setRefLen(reflens);
	/* For each reference, compute the TER */
	for (int i = 0; i < refs.size(); ++i) {
	    ref = (String) refs.get(i);
	    if(!refids.isEmpty())
		refid = refids.get(i);

	    if(has_span) {
		calc.setRefSpan(refspan);
		calc.setHypSpan(hypspan);
	    }

	    Alignment result = calc.TER(hyp, ref, costfunc);

	    if ((bestresult == null) || (bestresult.numEdits > result.numEdits)) {
		bestresult = result;
		if(!refids.isEmpty()) bestref = refid;
	    }

	    totwords += result.numWords;
	}
	bestresult.numWords = ((double) totwords) / ((double) refs.size());
	if(!refids.isEmpty()) bestresult.bestRef = bestref;
	return bestresult;	
    }