fix connection var, add logging