modified ruby in generator form.