refactoring for use in hth