Complete code for Assignment 2