delete pointer when finishing