some refactoring and added connection indicator