final version using std::maps