change accumulate to std::accumulate