fix the memory bug