updated time logic