optimize vanish and update function