generate cfg at end