Fix package upgrade logic