Refactored with mongoose.