public B next() throws IOException {

    if (nextIsPreviousResult) {
      nextIsPreviousResult = false;
      noMoreNext = true;
      return previousResult;
    }

    if (waitingNext) {
      waitingNext = false;
      previousResult = currLookup.next();

      if (matchingMode == MATCHING_MODE.LAST_MATCH || matchingMode == MATCHING_MODE.FIRST_MATCH) {
        previousResultRetrieved = true;
        noMoreNext = true;
      }

      return previousResult;
    } else {
      throw new NoSuchElementException();
    }
  }