Corrected function to calculate true ts