refactoring ch1~ch9