Optimizing the route-matcher logic for speed