made animation code conditional to a checkbox