fixed bugs in the primes method