fix a bug in reconnecting to mongodb