finished exercise 2 of assignment 3