add logic for duplicate records