fix so that connecting/disconnecting works properly when we return app to foreground