avoid segmentation fault of double destruction of unique_ptr