private double checkWindowBody(Query q, Map<String, List<Integer>> bodyHits, double curSmallestWindow) {
		double smallestWindow = Double.POSITIVE_INFINITY;
		List<String> queryWords = q.words;
		int queryLength = queryWords.size();
		
//		System.out.println("query = " + queryWords);
//		System.out.println("posting = " + bodyHits);
		
		// convert query words to lower case
		for (int i = 0; i < queryLength; i++) {
			String word = queryWords.get(i).toLowerCase();;
			queryWords.set(i, word);
		}
		
		// convert doc terms to lower case
		for (String term : bodyHits.keySet()) {
			bodyHits.put(term.toLowerCase(), bodyHits.get(term));
		}
		
		// if not all terms appear in the doc
		for (String term : queryWords) {
			if (!bodyHits.containsKey(term)) {
				return curSmallestWindow;
			}
		}
		
		// traverse through posting list, calculate smallest window size
		// record the current positions
		Map<String, Integer> curPositions = new HashMap<String, Integer>();
		for (String term : queryWords) {
			curPositions.put(term, 0);
		}
		while (true) {
			String smallestPosTerm = getSmallestPositionTerm(bodyHits, curPositions);
			int smallestPos = curPositions.get(smallestPosTerm);
			
			String largestPosTerm = getLargestPositionTerm(bodyHits, curPositions);
			int largestPos = curPositions.get(largestPosTerm);
			
			double begin = bodyHits.get(smallestPosTerm).get(smallestPos);
			double end = bodyHits.get(largestPosTerm).get(largestPos);
			double window = end - begin + 1;
			if (window < smallestWindow) smallestWindow = window;
			
			// already hit the end
			if (smallestPos >= bodyHits.get(smallestPosTerm).size() - 1) {
				break;
			}
			
			// advance the pointer
			curPositions.put(smallestPosTerm, smallestPos+1);
		}

//		System.out.println("curWindow = " + Double.toString(curSmallestWindow));
//		System.out.println("window = " + Double.toString(smallestWindow));
		return (smallestWindow < curSmallestWindow) ? 4*smallestWindow : curSmallestWindow;
	}