refactored ch4 and ch5 with name mods, ch6 with class and test