added code for generating h