Complete code for week 2