spexs algorithm implementation