corrected TMAX to make result independent of XMAX