finished exercise; yet to confirm whether the spec is correct