using requestAnimationFrame API