fixed endtime calculation