bug fix on clearIntervals function