I think this whole if/else block would fit nicely in a one-liner ternary assigment. But, of course, this is just personal style :)

Also, watch the consistency with line breaks around `} else {`