modified reconnect to only try connecting if disconnected // optimized code for send string method