fix the update logic