improving routing logic