improving performance for determining primes