Added the isRouteValid method.