Fixing bad-ptr