Rewrite getting timetables with GCD