using timeout instead of requestanimationframe