[lib] Rewrite the setup and update logic