rewrite ch17