trying to fix memory error