fixed addTable function