tidy chap16 and chap17