changed to requestanimationframe