Completed matching algorithm