bug fix checking duplicates