Bug: array_shift called on item of array rather than the array itself