fix type in writing out table 1 - add creation of table 2