public boolean sample() {
		if(rejectNonExact && curDist != targetDist)		// reject sample if distance does not match exactly
			return false;
		String key = curAli.toString();
		Integer cnt = sampleMap.get(key);
		if(cnt == null) {
			cnt = 1;
//			if(sampleMap.size()%100==99)
//				System.out.println("found: "+(sampleMap.size()+1));
//			if(sampleMap.size() == 220000)
//				return true;

			Integer cnt2 = distUniqs.get(curDist);
			cnt2 = cnt2 == null ? 1 : cnt2+1;
			distUniqs.put(curDist, cnt2);
		} else {
			cnt++;
		}
		if(cnt > maxCnt) {
			maxCnt = cnt;
			maxDist = curDist;
		}
		sampleMap.put(key, cnt);
		
		if(writeSamples && id == 0) {
			if(totalSamples == 0)
				sampleDCalc = new DistCalc(new Align(curAli.toRaw()));
			
			int d1 = distCalc.dist(curAli);		// distance from ref
			int d2 = sampleDCalc.dist(curAli);	// distance from first sample
//			sampleDCalc = new DistCalc(new Align(curAli.toRaw()));
			System.out.println((totalSamples+1)+"\t"+d1+"\t"+
					String.format(Locale.US, "%.2f", distCalc.dist2acc(d1))+"\t"+d2+"\t"+
					String.format(Locale.US, "%.2f", sampleDCalc.dist2acc(d2)));
			
			// write samples to files
			try {
				BufferedWriter w = new BufferedWriter(new FileWriter("sample"+(totalSamples+1)+".fsa"));
				w.write(key);
				w.close();
			} catch (Exception e) {
			}
		}

		totalSamples++;
		return true;
	}