modified as per HW3p3