fix next-time calculate algorithm