Improved matching algorithm with wildcard matcher