HW4 functional