using requestAnimationFrame to decrease use of CPU when generating flows