If I understand you correctly, you want to check if values exists in lists, Since you have a unique name, it's best to leverage that uniqueness in combination with a map, you start of by adding all the values in your lists to 2 maps. Map<String, Obj__c> objMap1 = new Map<String, Obj__c>(); Map<String, Obj__c> objMap2 = new Map<String, Obj__c>(); // List 1 for(Obj__c o : list1) { objMap1.put(o.UniqueName__c, o); } // List 2 for(Obj__c o : list2) { objMap2.put(o.UniqueName__c, o); } // Now you can easily check if that value is in your map by doing. objMap1.containsKey('WhateverYouWantToCompare'); // or objMap2.containsKey(newObj.UniqueName__c); ... do your logic