rewrite to use cfgmag