A helper function requires too many parameters to be cleaner than the current code, I'm moving the declaration down to the enclosing `if`.