Modify and add the code to complete assignment 2