fix rand issue