switch to using objects rather than nested arrays
Add record discriminator