Fixed and added isPrime function