added list flattening