bug fixes in the h conversion function