Implement the main upgrade logic