Optimized the parseRoute() method