logic updated for diff logic to be fast for large lists