Data science

Move the inner block to a separate method `valid_row?` so as to remove nesting.