completed mongo db refactoring