Get rid of duplicated code in hashtable package