Generate HTR in a more pythonic way