finished exercise 48 but need to refactor it