Change setInterval to requestAnimationFrame function