refactoring mongo