Implemented the openConnection Function