fix memory changing problem