rewrite for c++11