Refactoring route matching to handle more complex URLs and allow for route variables