HW3 functions