changed from interval to requestAnimationFrame