Fixed wrong activity being chosen and code clean up