making timetable dynamic attempt 2

fixed some logic errors