Code for week 10 assignment