Changed the code so that it can execute connection and disconnection command