DRYed the routing code