Update spm.py

First implementation