int splitWords_rec(int pos) {
		if (pos >= wdArr.length)
			return 0;

		// if it is already cached, don't bother calculate it again.
		if (cache[pos] >= 0)
			return cache[pos];

		int splits = 0;

		for (int len = 1; len <= dict.getMaxLen() && len + pos <= wdArr.length; len++) {
			// check if current string starts with a word in the dictionary
			String wd = String.valueOf(wdArr, pos, len);
			if (!dict.hasWord(wd)) {
				continue;
			}

			// if this word ends the whole string, we have found one split
			if (pos + len == wdArr.length) {
				stk.push(wd);
				// System.out.println(StringUtils.join(q, ","));
				stk.pop();
				splits++;
				continue;
			}

			// go ahead and split the string to the end.
			stk.add(wd);
			splits += splitWords_rec(pos + len);
			stk.remove(stk.size() - 1);
		}
		cache[pos] = splits;
		return splits;
	}