Please replace FlatMap function by Filter function.