move flow to model