Detect and remove duplicates in a list of inputs