Use unique_ptr to avoid possible memory leak