corrected TotalEnd calculation