updated code for assignment 2