optimize: eliminated table.insert() because it is slower than "tb[#tb + 1] = val".