C++ implementation: reformat