modified table2flat