refactoring slave msp code