improve the mongodb connection handler
improve the mongodb connection handler