rewriting with C++