created a hasDuplicates function