fixed some bugs and replaced hash_map by unordered_map