Don't like the fact that you have to iterate twice...
Could this be solved via a stream transformer ?