Refactors duplicate handling