Fixed loop in deduplicate tool JavaScript.