try to fix memory leak... but too hard