upgrade code for spm2
Merge pull request #1 from afc163/master

update code for spm2