Perhaps we could extract this to a method, make it more readable, and here we just call it with two callbacks, one if we need an upgrade and another if we needed.

Actually we could share this and use it in ftu, in the app.js file we do the same.