Fixed a bug in calculating the end time
Fixed a bug in calculating the end time