recursive search for matching method