I don't understand why the code below is not returning the `rate` variable. The weird thing is that right above the `return` statement there is a `puts` statement that actually does print out the right value for `rate`.

```
def irr(lower_guess, higher_guess, increment, *amounts)
  rate = lower_guess
  precision_level = 0.1
  while rate <= higher_guess
    present_value = present_value_of_series(rate, *amounts)
    if present_value < 0
      puts "in if 1" #debug
      if present_value >= -precision_level
        puts rate
        return rate
      else
        irr((rate-increment), rate, increment/10, *amounts)
        break
      end
    else
      rate += increment
    end
  end
end

```

Sample method call:

```
irr(0.0001, 0.50, 0.01, -11000, 1966.63, 1959.37, 1952.13, 1944.88, 1937.6399999999999, 1930.3999999999999)

```

Edit:
Added sample method call

Edit 2: I have applied the solution proposed by @Mark Reed, and now it works:

```
def irr(lower_guess, higher_guess, increment, *amounts)
  rate = lower_guess
  precision_level = 0.1
  while rate <= higher_guess
    present_value = present_value_of_series(rate, *amounts)
    if present_value < 0
      if present_value >= -precision_level
        break
      else
        rate = irr((rate-increment), rate, increment/10, *amounts)        
      end
    else
      rate += increment
    end
  end
  return rate
end

```