fix outofmemory error