Improve the way to connect to MongoDB