Part3 of homework2 assignment