code for assignment2