add check for mongodb errors