Update spm.py

added better search