properly handle connection in login activity