Added function to generate random code