working out some javascript data structures