added function gen_random_output