Added NaN protection.