Trying to fix memory problem