Finished the SPB algorithm