Added check for NaN.