handle NaN and Infinite numbers