`return tmp` in the middle of an `each` means that you are short circuiting the `each` and trying to find a specific value. In that case using `find` would be more appropriate than `each`.