clean up main logic