Simplify state return value
!foo.nil? => foo
Replace an .each with .find
Unpack triple instead of indexing into it
Eliminate redundant line
Make assignment easier to see