code fix memory leak