add error handling for mongo