No need for the copy if you calculate sortingCase before processing the mask.