Finish main logic for script.