refactoring and remote connection added