Matching algorithm fix