fix time logic bug