refactored mongoose setup