refactor lean flow