Replaces setTimeout with requestAnimationFrame