Refactor HOCR distillation to function