I would move this `version` handling outside, to a separate JS. Probably we could use a promise in order to check the version, and then check if it is an upgrade or not.