major rework of hui api function