separate main logic from command line loader.