improve the unique name assignment