Refactoring Data flow