Update flatMap definition (thanks @melix)