Finished exercise 2 of problem set 2