Move hrf function to its own module

DRY it out!