add option for flattening data