fix the wrong logic in update function