new mtching algorithm