The function used a global `ticker` variable but never incremented it inside the loop, causing an infinite loop if the first generated name was already in the used set. This fix removes the global state and uses the loop variable `i` directly, which is cleaner and avoids the bug.