add retry logic to connect to MongoDB