replaced vector with hash_map to get constant speed