fix memory potential leak