bug in calc_temp_dist fixed.