Fix:added an improvement to fix memory leak