fixed bug: deleting smart-ptr twice