Moved array_shift inside array check