Fix issue with checking duplicates