Adding rand_r replacement