Fixed ReduceTable() and tested it in main