Adding connection logic
resolved merge conflicts