Fixed setTimeout control