finished exercise 1 for HW2