Bug fix: Array recursion alters original array