Copy slice to avoid modifying it (which results in weird behavior)