finished exercise 2 of problem set 1