fix memory loses