Add NaN detection to therm

recursive call