clean up code in main