Optimized the use of std::map