connection logic