Fix bug and update function.