generating final table - modified