fix wrong hash table usage, split more general function from imdkit