Updated version of allowDuplicates after review

Updated code after initial review from Igor