Optimized random id choose operation