C++ bug fix