Simplifying the logic inside array recursion.