factored out unique name generation