Fix #47 Add a check to detect duplicates