added check for mongo connection