Fixed bug in update method