avoid arraycopy unless necessary, to improve performance