added option to flatten data lists