refactoring and mongodb