moved intent declaration and activity switch to onDestroy