Fixed the way a MongoDB connection is set up