Improved table code