starttime and endtime optimize