Part of HW3 and full HW4