rand_gen fix