Divide main into classes to increase readability and easier modification