fix bug in update method