fix memory leak issue