generalized connection logic