added TypeError check to prime_gen