HW1 functions