```ruby
0.upto(max_search - 1) do |j|
   ...
end
```