Duplicate array only if neccessary