code for Assignment 3