Fixed possible runtime error in inactivityLoop()