Refactor flows