new implementation using a flat array and a parallel flatMap