better handling of nans