Fixed edge cases for get_primes function