recursion inject modifies the array