solve memory leak