fixed blinking bug, added requestAnimationFrame usage