fixed setTimeout and setInterval related issues