Dedupe logic