fix memory leak bug