Solution to class exerice.