Find and remove duplicates in a list