Use setInterval instead of calling setTimeout continuously.