code change

made the intensity calculation for toggle animation, set a variable first.