Comparison application I'm making a comparing section, which I've just started typing, trying to get something working. It's working now, but as you can see its pretty messy.  I feel this could be done in one or two less queries, or I should break it apart into smaller methods.

foreach (XMLObject source in Sources)
{
    var matchedElement =
        destList.FirstOrDefault(s.ElementName == source.ElementName);
        // checks to see if it exists in one list but not the other

    if (matchedElement == null) // element is in one list and not the other
    {
        var alter =
            lstAlteration.FirstOrDefault(
                a =&gt; a.ElementName == source.ElementName &amp;&amp; a.ChangeInfo.ChangeFrom == source.ElementName);
            // check to see if the the element is a Removal (Changed From would not be blank)

        if (alter == null) // Removal has not been triggered
        {
            alter = new Alteration
                        {
                            ElementName = source.ElementName,
                            ChangeInfo = new ChangeDetail( {ChangeTo = source.ElementName}
                        };
        }
        else
        {
            alter.ChangeInfo.ChangeTo = source.ElementName;
        }

        lstAlteration.Add(alter);
    }
}
foreach (var source in Sources.Where(x =&gt; !destList.Exists(s =&gt; s.ElementName == x.ElementName))
{
    var alter = lstAlteration.FirstOrDefault(a =&gt; a.ElementName == source.ElementName
                                 &amp;&amp; a.ChangeInfo.ChangeFrom == source.ElementName);

    if (alter == null) {
        alter = new Alteration
                    {
                        ElementName = source.ElementName,
                        ChangeInfo = new ChangeDetail()
                    };

        lstAlteration.Add(alter);
    }

    alter.ChangeInfo.ChangeTo = source.ElementName;
}



Sorter
Only one .ChangeInfo.ChangeTo = source.ElementName; execution