code for generating table