refactor move flow to mongo