add code for spfa