upgrade main logic