The better solution with reduced memory usage