Refactored contains() and doesContain() methods.