Perhaps the `if` block should check running apps instead of currently active app.