you probably don't need this flag at all - you could `return` from inside of the `try` block if connection is successful and retry from after the catch block..