first half of HW4 part1 implemented.
finished HW4 part1.