reformat code in slide 8