Better impl avoid outofmemory