creted a failed connection counter that tracks the number of consecutive failed connections and terminates program after 10 failed attempts