Rewritten MongoDB connection