Added new helper to check if a number is prime.