Updated the buildTable function.