fixed bugs in update.