copy data before modifiying it