Added some connection logic