main cfg_building function typed