add to_h function.