initial import of c++ version