fix connection to use environment; needs more work