refactoring flow