changed isDuplicate function to hasDuplicates