maybe this way it better

I find that rand's global function has lock itself.