changed flatten to kunfold