Refactored to support remote connections based on environment variable MONGODB_CONNECT