fix memory leakage