updated connection method for mongodb