implement flatMap on stream