added code attribute to keep track of whether the code was randomly generated or entered by the user