Refactor

Syntax is a little weird, but probably ok.  nil check I presume?