refactoring variable names, adding discovery retry, start auto reconnect only when connection is made