implemented HW3-part3