added a check that connection exists to server, haven't tested it yet