Finished random generation code