updated isPrime method