handle duplicates by checking existence