ch 18 rewriting cmp