Replaced setTimeout with requestAnimationFilterFrame