refactored mongoose model to schema, error handling for db connection