improve update logic