bug fix on duplicates