trying to fix memory errors