used requestAnimationFrame to update canvas