Why won't this script lookup wildcard matches?

Why won't this script lookup wildcard matches?

I'm looking up two fields here, Case_Name and Adverse_Party to see if there is any wildcard match in the database. Adverse_Party works fine in this script but Case_Name only shows a match on the current entry and never matches any historic data even though I know there should be matches. What's going wrong?
 
 
  1. cnt=count(Case_Management_Form[(Case_Name.contains(input.Case_Name) || (Adverse_Party.contains(input.Adverse_Party) && Case_Code != input.Case_Code))]);
    if((cnt > 0))
    {
        records = Case_Management_Form[Case_Name.contains(input.Case_Name)];
        email_body_case_name="";
        for each r in records
        {
            email_body_case_name=email_body_case_name + r.Case_Code + " " + r.Case_Name + "<br />" + "\n";
            ///case name matches for email ;)
        }
        records = Case_Management_Form[Adverse_Party.contains(input.Adverse_Party)];
        email_body_adverse_party="";
        for each r in records
        {
            email_body_adverse_party=email_body_adverse_party + r.Case_Code + " " + r.Adverse_Party + "<br />" + "\n";
            ///adverse party matches for email ;)
        }
        //then use in email.
    }