change to scoped_pointer from raw pointer