Avoiding collisions with random id generation