update weights and words