the change in getRoutesByNames should not be needed. the loop is only needed if there actually is a prefix. what you propose ends up in a complicated way to copy $names into $routes.