refactored a flow