Completed and working code for Assignment 2