Added a nested query - it works... still need to work out how to generalise the types.