solve memory bug