Switch from setInterval to requestAnimationFrame