Primes with error checking