move global $CONFIG; up to start of function