Converted fully to c++