changed the loop code. using requestAnimationFrame()