fixed an error in the primality function