what is the reason to copy input array instead of just modifying it?