new version -- flatten prog