Improve duplicate handling