pair pattern matching for equality check