Optimization for bus routing