little change in table-ifying algorithm