Exercise 2.89: Improve performance of adjoin-term