Converted to c++