If you do:

```ruby
if rid == -1
    return
end
```
would allow you to easily reduce the complexity of this block of code by 1 level. It for sure, would help to code readability :)