flattenAt functions added