Part2 of homework2 assignment