clean up the main part of the code.