nit: it's generally good for readability to reduce variable "lifetime" and there's no real reason for `cfg` to be declared at this point; could move it down to right before it's first used.