nit: just `array_shift` before the loop?