@Override
  public TripRouter instantiateAndConfigureTripRouter(RoutingContext routingContext) {
    // TODO Auto-generated method stub

    final TripRouter router = delegate.instantiateAndConfigureTripRouter(routingContext);

    // add our module to the instance
    router.setRoutingModule("movingpathways", new AAMRoutingModule(this.scenario));

    /*
    router.setRoutingModule(TransportMode.pt,
    		new TransitMultiModalAccessRoutingModule(
    				scenario,
    				new InitialNodeRouter(
    					router.getRoutingModule( "movingpathways" ),
    					scenario.getConfig().transitRouter().getSearchRadius(),
    					1,
    					scoringParams )

    				) );

    */
    final MainModeIdentifier defaultModeIdentifier = router.getMainModeIdentifier();
    router.setMainModeIdentifier(
        new MainModeIdentifier() {
          @Override
          public String identifyMainMode(final List<? extends PlanElement> tripElements) {
            boolean hadMovingPathway = false;
            for (PlanElement pe : tripElements) {
              if (pe instanceof Leg) {
                final Leg l = (Leg) pe;
                if (l.getMode().equals("movingpathways")) {
                  hadMovingPathway = true;
                }
                if (l.getMode().equals(TransportMode.transit_walk)) {
                  return TransportMode.pt;
                }
              }
            }

            if (hadMovingPathway) {
              // there were bike sharing legs but no transit walk
              return "movingpathways";
            }

            return defaultModeIdentifier.identifyMainMode(tripElements);
          }
        });

    return router;
  }