trying to fix memory leak