first working version for unwinding nested arrays
first working version for unwinding nested arrays