fix a memory bug