tweaks on table writing code