finished part2(a)