public boolean isPrime(long l) {

		// extend our list of primes if necessary in order to search for l
		while (maxPrimeFound < l) {
			this.getNext();
		}

		// now binary search for l
		int lo = 1;
		int hi = numPrimesFound;

		while (true) {
			int mid = (lo+hi) / 2;
			long midPrime = primesFound.get(mid);
			if (midPrime == l) {
				return true;
			} else if (Math.abs(hi-lo) <= 1) {
				// bottom out case
				// actually all base cases at once, so we don't have to be precise about even/odd 1-or-2
				if ((primesFound.get(lo) == l) || (primesFound.get(hi) == l)) {
					return true;
				} else {
					return false;
				} 
			} else if (midPrime < l) {
				lo = mid;
			} else {
				hi = mid;
			}
		}
	}