Revamped thread logic. Activating app starts a looping thread in background