correct mongodb error handling