Changed upgrade call to be a function. Also added try catch to the upgrades as there seems to be a bug with the buyAllAvailableUpgrades() method.