restructured msp code