refactor hash_char_positions