...a bit of refactoring for mongodb