Refactored GetRouteByName() function.