refactoring
first working copy of all the flow