Refine Upgrade algorithm