fixed bug for primes_upto accessing primes.back() when it might not have any elements