change refresh method to requestAnimationFrame