#13 new function sim_gen()