new matching algorithm