fixes bug for generating tables