Rewrite in C++