Refactoring flatMap -> flatmap