implemented matching logic and functionality