Refactor method to check if a number is a prime to be a little more efficient.