refactored ch3 and ch4 with classes, added ch4 test