add isnan check