finished exercise in ruby