hw2 part2 implemented