started port to c++, NOT WORKING!