cleaned up main script.