Changed to requestAnimationFrame with setTimeout callback