refactor flow app with mongodb