removed max(primes) check