fix logic to create table headers.