added mongodb errors handling