extracted table writing from write_parser