Refactoring for kh_put