added code for assignment 3