reference count issue. maybe due to c++