public int lookup(String key) {
		int index = 0;
		int base = 1; // base at index 0 should be 1

		int keyLength = key.length();
		for(int i = 0; i < keyLength; i++) {
			int previous = index;
			index = index + base + key.charAt(i);

			if(index > baseBuffer.limit()) { // Too long
				return -1;
			}

			base = baseBuffer.get(index);

			if (base == 0 ) { // Didn't find match
				return -1;
			}

			if(checkBuffer.get(index) != previous){	// check doesn't match
				return -1;
			}

			if(base >= TAIL_OFFSET) {	// If base is bigger than TAIL_OFFSET, start processing "tail"
				return matchTail(base, index, key.substring(i + 1));
			}

		}

		// If we reach at the end of input keyword, check if it is complete match by looking for following terminating character
		int endIndex = index + base + TERMINATING_CHARACTER;

		return checkBuffer.get(endIndex) == index ? index : 0;
	}