code for Assignment2