refactor hashmap