public boolean matches(int[] search, int[] ref, int offset) {
    int index = offset;
    for (int x = 0; x < search.length; x++) {
      if (ref[x] != search[index])
        return false;
      index++;
      if (index == search.length) {
        index = 0;
      }
    }
    return true;
  }