refactoring MongoDB service