fix route matching logic