FIX: generated text should never trigger an update
use not in instead of .has_key()
FIX: used a variable before assigning it.