Fixed error with NaN input