Implemented HW3 part 3