rejigging data structure but it's all a bit broken at the moment