refactor hugetbl code