converted to C++