updated timetable algorithm