created matching algorithm