fixed bug in update method