refactoring code to be used by slave nodes