finish ch6 code cleaning