fix "C++ object already deleted"