Refactor handling of `Contains`