refactor mongo