Better checking for nans