optimizing checkPackagesForDuplicates()