Improves get_primes function.