refactor unique name function