fix possible memory bug with gc