refactor the flow of the app