Re-write in C++