What I'm trying to point out with the duplication is the f.is_a?(Hash) stuff in the second else.

I think it might be better to write it this way if you're going to rely on recursion


```ruby
def build_fields_params(fields)
  if fields.is_a?(Hash) && !fields.empty?
    fields.map {|index,value| "#{index}:(#{build_fields_params(value)})" }.join(',')
  elsif fields.respond_to?(:each)
    fields.map {|field| build_fields_params(field) }.join(',')
  else
    fields.to_s.gsub("_", "-")
  end
end
```