fixed error connecting after app is declared