better error handling for mongo