Use HashMap::entry instead of HashMap::insert