a fixes of gen_rand_int & add sample_wor (tested)