Create buildRouteFunction