begintime and endtime are now handled correctly