logic in finding matching pairs