Modified to work with upgrades