Performance improvement with requestAnimationFrame