Completed problem part3 for assignment1