using requestAnimationFrame instead of setInterval