Random generation code added