mongoose refactoring