Fixed double free fault with smart pointer