implement containing element matching logic