conversion to flattened list function generation