Refactoring for mongoose and models