code refactoring for upgrading node