Completed code for assignment 2