Improve scaling replacing std::find with map