refactored a bit, added primes