unbox and foreach functions to unpack and build list structure