fixed outofmemory errors