Alexander Nicolaysen Sørnes : bug: Move duplicate detection to a separate function