apply mask on array