Simplify flattening of a list