Fixed bug when creating UID for duplicates