Appellant was committed to the California Youth Authority (CYA) for a burglary, and the juvenile court aggregated his previously sustained petitions to identify a maximum confinement time of 13 years and 10 months. Appellant asked the court to dismiss the prior sex offenses he admitted in 2001 or make the CYA commitment solely on the burglary count in order to avoid him being required to register as a sex offender. The court refused to do so, and said that it did not have the discretion to not include the sex offenses in the aggregated sentence. On appeal, appellant contended that the juvenile court failed to exercise its discretion with respect to the aggregation of the previous petitions. The appellate court agreed and remanded for resentencing. The juvenile court erroneously believed that it lacked discretion to decline to aggregate appellant’s previously sustained petitions. The court has the discretion and must exercise it to set the appropriate maximum term of confinement based upon the facts of the offenses on which it chooses to impose a CYA commitment. The registration requirement is intended to apply only to persons who were committed to CYA because of a sex offense. Therefore, if appellant had been committed to CYA only for non-sex offenses he would not have had to register despite his 2001 admission.