fix for OutOfBound exception in copyarray