started porting to c++