Fixed a bug in buildTable function.