Refactor transit window code