update loop code