uses less allocations by reusing memory