Copy array to avoid segmentation