Fixed isPrime function.