code for HW3