Modified Code for assignment 2